<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib  prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib  prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib  prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="redis" uri="http://www.shopjsp.com/redisTag/functions" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<c:set var="srcPath" value="${redis:getSysConfig('sysFileVisitRoot_back')}"/>
<c:set var="basePath" value="${redis:getSysConfig('base_path_back')}"/>
<c:set var="uploadPath" value="${redis:getSysConfig('uploadFileVisitRoot')}"/>
<c:set var="htmlPath" value="${redis:getSysConfig('in_path_html')}"/>
<c:set var="defaultImg" value="${redis:getSysConfig('website_default_img')}"/>
 <script type="text/javascript">
 //买家等级升迁
 function customerBuyers(){
		var id=$('input[name="buyersLevel"]:checked').val();
		var customerId=$("#customerId").val();
		var remark=$("#remark").val();
		if( id !=$("#dbuyersLevel").val()){
			if(remark !=""){
				$.ajax({
					type: "POST",
					dataType: "JSON",
					url : "${basePath}/back/buyersRecord/savaOrUpdateBuyersRecord.sjson",
					data: {id:id,remark:remark,customerId:customerId},
					success: function(data){
					if(data.success==true){
						$("#tt").datagrid("reload"); //保存后重新加载列表
					}else{
						msgShow("系统提示", "<p class='tipInfo'>请重新选择，操作失败！</p>", "warning");
					}
						closeWin();
					}
				});
			}else{
				msgShow("系统提示", "<p class='tipInfo'>备注不能为空，请重新操作！</p>", "warning");
			}
		}else{
			msgShow("系统提示", "<p class='tipInfo'>请重新选择，操作失败！</p>", "warning");
		}
 }
</script>
  <div id="addOrEditWin">
		<form id="form1"  method="post" action="">
			<input id="ratingRecordId" type="text" name="ratingRecordId" value="" noclear="true"/>
			<input id="customerId" type="text" name="customerId" value="${customerId}" noclear="true"/>
			<input id="dbuyersLevel1" type="text" name="buyersLevel" value="" noclear="true"/>
				<table align="center" class="addOrEditTable" style="width: 700px;">
					<tr>
		      			<td class="toright_td" width="50px">操作人:</td>
		      			<td  class="toleft_td"><span style="color:green;font-weight:bolder">${sessionScope.users.userName}</span></td>
		    		</tr>
					<tr>
						<td class="toright_td" width="70px">等级策略:</td>
		     				<td class="toleft_td" width="300px" >
		     					<table class="toleft_td" class="addOrEditTable" style="width:610px; margin-top:0">
		     						<tr>
		     							<td style="font-weight:bold;">选择</td><td style="font-weight:bold;">买家等级</td><td style="font-weight:bold;">买家头衔</td><td style="font-weight:bold;">等级折扣值(%) </td><td style="font-weight:bold;">等级图标</td>
		     							<td style="font-weight:bold;">最小参考值</td><td style="font-weight:bold;">最大参考值</td><!-- <th>授信额度(￥)</th><th>授信期限(天)</th> -->
		     						</tr>
		     						<c:forEach items="${listBuyersStrategy}" var="lb" varStatus="s">
			     						<tr>
			     							<td>
			     								<input  type="radio" id="level_<c:out value='${lb.buyersLevel}'/>" name="buyersLevel" <c:if test="${s.index==0}">checked="checked"</c:if> value="<c:out value='${lb.buyersLevel}'/>">
			     							</td>
			     							<td><c:out value='${lb.buyersLevel}' /></td>
			     							<td><c:out value='${lb.buyerRank}' /></td>
			     							<td><c:out value='${lb.levelDiscountValue}' /></td>
			     							<td><div><img src='<c:out value='${uploadPath}'/><c:out value='${lb.levelIcon}' />'  /></div></td>
			     							<td><c:out value='${lb.minRefValue}' /></td>
			     							<td><c:out value='${lb.maxRefValue}' /></td>
			     						</tr>
		     						</c:forEach>
		     					</table>
		     				</td>
		    		</tr>
		    		<tr>
				      <td class="toright_td" width="50px"><span style="color:red">* </span>备注:</td>
				      <td class="toleft_td">
				      	<textarea id="remark" rows="3" cols="40" style="width:604px;height:35px;" name="buyersRecord.remark" class="{validate:{required:true,maxlength:[250]}}"></textarea>
				      </td>
				    </tr>
				</table>
			    <div class="editButton"  data-options="region:'south',border:false" >
					<a id="btnSave" class="easyui-linkbutton" icon="icon-save" onclick="customerBuyers()" href="javascript:;">保存</a>
			    	<a id="btnCancel" class="easyui-linkbutton" icon="icon-cancel" onclick="closeWin()" href="javascript:;">取消</a>
			    </div>
	</form>
  </div>
